package com.example.demo;

import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;

import androidx.annotation.NonNull;

import com.example.demo.splash.MainSplashScreen;

import java.io.ByteArrayOutputStream;

public class MainChannelImpl {

    private MainChannelImpl() {

    }

    /**
     * 获取原生对应的引导页的图片内容，转化uint8list给到flutter
     *
     * @param resources Resources 资源类
     */
    public static byte[] getAppResourceImage(@NonNull Resources resources, int resourceId) {
        Bitmap bitmap = BitmapFactory.decodeResource(resources, resourceId);
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        boolean byteSuccess = bitmap.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream);
        return byteSuccess ? byteArrayOutputStream.toByteArray() : null;
    }
}
